import { Ajax } from '../utils/http';


export class VideoService {
    private page: number;
    constructor(_page: number) {

        this.page = _page;
    }

    public async send(): Promise<VideoData> {
        let response: VideoData;
        let data = {
            p: this.page,
            psize: 12
        }
        try {
            response = await new Ajax<VideoData>('/index/videoList', data).post();
        } catch (e) {
            throw e;
        }
        return response;
    }
}


export class VideoDetailService {
    private id: number;
    constructor(_id: number) {

        this.id = _id;
    }

    public async send(): Promise<VideoDetail> {
        let response: VideoDetail;
        let data = {
            id: this.id,
        }
        try {
            response = await new Ajax<VideoDetail>('/article/videoInfo', data).post();
        } catch (e) {
            throw e;
        }
        return response;
    }
}

/*Data*/
export interface VideoDetail {
    id: string;
    title: string;
    thumb: string;
    viewcount: number;
    collectcount: string;
    likecount: string;
    url: string;
    videoid: string;
    duration: number;
    coverURL: string;
    isfollow: number;
    islike: number;
  }
  

/*List*/
export interface VideoItem {
    id: string;
    title: string;
    abstract: string;
    thumb: string;
    url: string;
    viewcount: string;
    collectcount: string;
    likecount: string;
    createtime: string;
    isfollow: number;
    islike: number;
}

/*Data*/
export interface VideoData {
    list: VideoItem[];
    total: number;
}
